package com.wrx.server.controller;


import com.wrx.server.pojo.PageBean;
import com.wrx.server.pojo.ReplyPost;
import com.wrx.server.pojo.ReplyPostModel;
import com.wrx.server.pojo.RespBean;
import com.wrx.server.service.IReplyPostService;
import com.wrx.server.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wrx
 * @since 2021-04-20
 */
@RestController
//@RequestMapping("/server/reply-post")
public class ReplyPostController {

    @Autowired
    IReplyPostService replyPostService;

    @ApiOperation(value = "分页输出主题帖中的回帖")
    @PostMapping("/ReplyPost/putPageReplyPost")
    public RespBean putPageReplyPost(@RequestBody PageBean pageReplyBean){
        int theme_post_id = pageReplyBean.getNum1();
        int orderByType = pageReplyBean.getState();
        System.out.println(theme_post_id+" "+pageReplyBean.getPageNum()+" "+pageReplyBean.getPageSize()+" "+" "+orderByType);
        return replyPostService.putPageReplyPost(theme_post_id,pageReplyBean.getPageNum(),pageReplyBean.getPageSize(),orderByType);
    }

    @ApiOperation(value = "回帖主题帖")
    @PostMapping("/ReplyPost/addReplyPost")
    public RespBean addReplyPost(@RequestBody ReplyPost replyPost, HttpServletRequest request){
        return replyPostService.addReplyPost(replyPost,request);
    }

    @ApiOperation(value = "该回帖拥有者删除该回复")
    @PostMapping("/ReplyPost/delReplyPost")
    public RespBean delReplyPost(@RequestBody ReplyPostModel replyPostModel, HttpServletRequest request){
        return replyPostService.delReplyPost(replyPostModel,request);
    }


}
